<template>
  <div class="tem-container">
    <div>
      <el-button class="tem-back" type="primary" size="mini" @click="goBack">返回</el-button>
    </div>
    <div class="tem-testarea">
      <download-excel
        class = "export-excel-wrapper"
        :data = "json_data"
        :fields = "json_fields"
        :name = "exName">
        <!-- 上面可以自定义自己的样式，还可以引用其他组件button -->
        <el-button type="primary" size="small">导出EXCEL</el-button>
      </download-excel>
      <el-container>
        <el-main style="height: 100%">
          <el-scrollbar>
          <article v-html="value" ></article>
          </el-scrollbar>
        </el-main>
      </el-container>
    </div>
  </div>
</template>
<script>
export default {
  data () {
    return {
      value: `<article data-v-37f8e442=""><h1><a id="_0"></a>啊啊啊</h1>
              <pre><code>斤斤计较
              @RequestMapping("/hello")
              public String getHello(String aa){
                  System.out.println(aa);
                  return "hello";
              }
              </code></pre>
              <p></p></article>`,
      exName: 'textExcel.xls',
      json_fields: {
        "Complete name": "name",    //常规字段
        Telephone: "phone.mobile", //支持嵌套属性
        "Telephone 2": {
          field: "phone.landline",
                    //自定义回调函数
          callback: value => {
            return `Landline Phone - ${value}`;
          }
        }
      },
      json_data: [
        {
          name: "Tony Peña",
          city: "New York",
          country: "United States",
          birthdate: "1978-03-15",
          phone: {
            mobile: "1-541-754-3010",
            landline: "(541) 754-3010"
          }
        },
        {
          name: "Thessaloniki",
          city: "Athens",
          country: "Greece",
          birthdate: "1987-11-23",
          phone: {
            mobile: "+1 855 275 5071",
            landline: "(2741) 2621-244"
          }
        }
      ],
      json_meta: [
        [
          {
            " key ": " charset ",
            " value ": " utf- 8 "
          }
        ]
      ]
    }
  },
  methods: {
    goBack(){
        this.$router.go(-1)
    }
  }
}
</script>
<style scoped>
.tem-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}
.tem-back {
  float: left;
  margin: 0 0 10px 0;
}
.tem-testarea {
  width: calc(100% - 20px);
  height: calc(100% - 60px);
  background: #fff;
  box-shadow: 0 0 5px #ccc;
}
</style>